/*
* @Author: ls-mac
* @Date:   2018-09-03 16:01:26
* @Last Modified by:   ls-mac
* @Last Modified time: 2018-09-03 17:02:51
*/
import React, { PureComponent, Fragment } from 'react';
import moment from 'moment';
import { Form, Input, Select, Button,TimePicker,DatePicker } from 'antd';

class TimeRange extends PureComponent {
  constructor(props) {
    super(props);

    const value = props.value || {};
    this.state = {
      yearToDay: value.yearToDay || 0,
      startTime: value.startTime || '',
      endTime:value.endTime || '',
    };
  }

  componentWillReceiveProps(nextProps) {
    // clean state
    if ('value' in nextProps) {
      const value = nextProps.value;
      this.setState(value);
    }
  }


  render() {
    const state = this.state;
    return (
      <span><DatePicker defaultValue={moment(state.yearToDay)} /><TimePicker defaultValue={moment(state.startTime)} />~<TimePicker defaultValue={moment(state.endTime)} /></span>

        )
  }
}

export default TimeRange;
